

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>federatedml.feature.test.imputer_test &mdash; FATE 1.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../../../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../../../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../../../_static/doctools.js"></script>
        <script type="text/javascript" src="../../../../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../../../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../../index.html" class="icon icon-home"> FATE
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../../index.html">FATE</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../../../index.html">Module code</a> &raquo;</li>
        
      <li>federatedml.feature.test.imputer_test</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for federatedml.feature.test.imputer_test</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">unittest</span>

<span class="kn">from</span> <span class="nn">arch.api</span> <span class="k">import</span> <span class="n">eggroll</span>
<span class="kn">from</span> <span class="nn">federatedml.feature.imputer</span> <span class="k">import</span> <span class="n">Imputer</span>


<div class="viewcode-block" id="TestMinMaxScaler"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler">[docs]</a><span class="k">class</span> <span class="nc">TestMinMaxScaler</span><span class="p">(</span><span class="n">unittest</span><span class="o">.</span><span class="n">TestCase</span><span class="p">):</span>
<div class="viewcode-block" id="TestMinMaxScaler.setUp"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.setUp">[docs]</a>    <span class="k">def</span> <span class="nf">setUp</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">str_time</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">%H%M%S&quot;</span><span class="p">,</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">())</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">test_data</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">[</span><span class="s2">&quot;0.254879&quot;</span><span class="p">,</span> <span class="s2">&quot;na&quot;</span><span class="p">,</span> <span class="s2">&quot;0.209656&quot;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.441366&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.485934&quot;</span><span class="p">,</span> <span class="s2">&quot;na&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.287570&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.733474&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-1.142928&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.166747&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.923578&quot;</span><span class="p">,</span> <span class="s2">&quot;0.628230&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.021418&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.111867&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.959523&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.096672&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-0.121683&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-1.451067&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.406518&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.092337&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.168557&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.305831&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.745063&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.499499&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-0.302893&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-0.879933&quot;</span><span class="p">,</span> <span class="s2">&quot;null&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.877527&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.780484&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.037534&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.483880&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.555498&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.768581&quot;</span><span class="p">,</span>
             <span class="s2">&quot;0.433960&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.200928&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;0.426758&quot;</span><span class="p">,</span> <span class="s2">&quot;0.723479&quot;</span><span class="p">,</span> <span class="s2">&quot;0.316885&quot;</span><span class="p">,</span> <span class="s2">&quot;0.287273&quot;</span><span class="p">,</span> <span class="s2">&quot;1.000835&quot;</span><span class="p">,</span> <span class="s2">&quot;0.962702&quot;</span><span class="p">,</span> <span class="s2">&quot;1.077099&quot;</span><span class="p">,</span> <span class="s2">&quot;1.053586&quot;</span><span class="p">,</span> <span class="s2">&quot;2.996525&quot;</span><span class="p">,</span>
             <span class="s2">&quot;0.961696&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;0.963102&quot;</span><span class="p">,</span> <span class="s2">&quot;1.467675&quot;</span><span class="p">,</span> <span class="s2">&quot;0.829202&quot;</span><span class="p">,</span> <span class="s2">&quot;0.772457&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.038076&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.468613&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.307946&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.015321&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-0.641864&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.247477&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-0.662496&quot;</span><span class="p">,</span> <span class="s2">&quot;0.212149&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.620475&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.632995&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.327392&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.385278&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.077665&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.730362&quot;</span><span class="p">,</span>
             <span class="s2">&quot;0.217178&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.061280&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-0.453343&quot;</span><span class="p">,</span> <span class="s2">&quot;-2.147457&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.473631&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.483572&quot;</span><span class="p">,</span> <span class="s2">&quot;0.558093&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.740244&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.896170&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.617229&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-0.308601&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.666975&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-0.606584&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.971725&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.678558&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.591332&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.963013&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.302401&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.212855&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.321154&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-1.591501&quot;</span><span class="p">,</span> <span class="s2">&quot;-1.230554&quot;</span><span class="p">],</span>
            <span class="p">[</span><span class="s2">&quot;-0.583805&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.193332&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.633283&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.560041&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.349310&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.519504&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.610669&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.929526&quot;</span><span class="p">,</span>
             <span class="s2">&quot;-0.196974&quot;</span><span class="p">,</span> <span class="s2">&quot;-0.151608&quot;</span><span class="p">]</span>
        <span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">test_instance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">td</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">test_instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">td</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_to_eggroll_table</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_instance</span><span class="p">,</span> <span class="n">str_time</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="o">.</span><span class="n">schema</span><span class="p">[</span><span class="s1">&#39;header&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;fid&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">[</span><span class="mi">0</span><span class="p">]))]</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.print_table"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.print_table">[docs]</a>    <span class="k">def</span> <span class="nf">print_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">collect</span><span class="p">())):</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">features</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.data_to_eggroll_table"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.data_to_eggroll_table">[docs]</a>    <span class="k">def</span> <span class="nf">data_to_eggroll_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">jobid</span><span class="p">,</span> <span class="n">partition</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">work_mode</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="n">eggroll</span><span class="o">.</span><span class="n">init</span><span class="p">(</span><span class="n">jobid</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="n">work_mode</span><span class="p">)</span>
        <span class="n">data_table</span> <span class="o">=</span> <span class="n">eggroll</span><span class="o">.</span><span class="n">parallelize</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">include_key</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">partition</span><span class="o">=</span><span class="n">partition</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">data_table</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.table_to_list"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.table_to_list">[docs]</a>    <span class="k">def</span> <span class="nf">table_to_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table_instance</span><span class="p">):</span>
        <span class="n">res_list</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">table_instance</span><span class="o">.</span><span class="n">collect</span><span class="p">()):</span>
            <span class="n">res_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">res_list</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.fit_test_data"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.fit_test_data">[docs]</a>    <span class="k">def</span> <span class="nf">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">fit_values</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">])):</span>
                <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="ow">in</span> <span class="n">imputer_value</span><span class="p">:</span>
                    <span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">fit_values</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="k">return</span> <span class="n">data</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.fit_test_data_float"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.fit_test_data_float">[docs]</a>    <span class="k">def</span> <span class="nf">fit_test_data_float</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">fit_values</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">])):</span>
                <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="ow">in</span> <span class="n">imputer_value</span><span class="p">:</span>
                    <span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">fit_values</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">])</span>
        <span class="k">return</span> <span class="n">data</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_min"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_min">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_min</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;min&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="mf">1.451067</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.147457</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.166747</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.092337</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.037534</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.302401</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.305831</span><span class="p">,</span>
                                            <span class="o">-</span><span class="mf">1.745063</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.591501</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.230554</span><span class="p">]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_max"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_max">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_max</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;max&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.963102</span><span class="p">,</span> <span class="mf">1.467675</span><span class="p">,</span> <span class="mf">0.829202</span><span class="p">,</span> <span class="mf">0.772457</span><span class="p">,</span> <span class="mf">1.000835</span><span class="p">,</span> <span class="mf">0.962702</span><span class="p">,</span> <span class="mf">1.077099</span><span class="p">,</span>
                                            <span class="mf">1.053586</span><span class="p">,</span> <span class="mf">2.996525</span><span class="p">,</span> <span class="mf">0.961696</span><span class="p">]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_mean"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_mean">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_mean</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;mean&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="mf">0.413542</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.330818</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.343831</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.444957</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.107726</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.569688</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.548734</span><span class="p">,</span>
                                            <span class="o">-</span><span class="mf">0.670353</span><span class="p">,</span> <span class="mf">0.002498</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.275518</span><span class="p">]</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_replace_value"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_replace_value">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_replace_value</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;NA&#39;</span><span class="p">,</span> <span class="s1">&#39;naaa&#39;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="n">replace_method</span><span class="o">=</span><span class="s2">&quot;designated&quot;</span><span class="p">,</span>
                                                         <span class="n">replace_value</span><span class="o">=</span><span class="s1">&#39;111111&#39;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;111111&#39;</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">)]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_none_replace_method"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_none_replace_method">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_none_replace_method</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;NA&#39;</span><span class="p">,</span> <span class="s1">&#39;naaa&#39;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;0&#39;</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">)]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_max_float"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_max_float">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_max_float</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;max&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;float&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.963102</span><span class="p">,</span> <span class="mf">1.467675</span><span class="p">,</span> <span class="mf">0.829202</span><span class="p">,</span> <span class="mf">0.772457</span><span class="p">,</span> <span class="mf">1.000835</span><span class="p">,</span> <span class="mf">0.962702</span><span class="p">,</span> <span class="mf">1.077099</span><span class="p">,</span>
                                            <span class="mf">1.053586</span><span class="p">,</span> <span class="mf">2.996525</span><span class="p">,</span> <span class="mf">0.961696</span><span class="p">]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data_float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_transform"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_transform">[docs]</a>    <span class="k">def</span> <span class="nf">test_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.963102</span><span class="p">,</span> <span class="mf">1.467675</span><span class="p">,</span> <span class="mf">0.829202</span><span class="p">,</span> <span class="mf">0.772457</span><span class="p">,</span> <span class="mf">1.000835</span><span class="p">,</span> <span class="mf">0.962702</span><span class="p">,</span> <span class="mf">1.077099</span><span class="p">,</span>
                                            <span class="mf">1.053586</span><span class="p">,</span> <span class="mf">2.996525</span><span class="p">,</span> <span class="mf">0.961696</span><span class="p">]</span>
        <span class="n">process_data</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_transform_float"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_transform_float">[docs]</a>    <span class="k">def</span> <span class="nf">test_transform_float</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.963102</span><span class="p">,</span> <span class="mf">1.467675</span><span class="p">,</span> <span class="mf">0.829202</span><span class="p">,</span> <span class="mf">0.772457</span><span class="p">,</span> <span class="mf">1.000835</span><span class="p">,</span> <span class="mf">0.962702</span><span class="p">,</span> <span class="mf">1.077099</span><span class="p">,</span>
                                            <span class="mf">1.053586</span><span class="p">,</span> <span class="mf">2.996525</span><span class="p">,</span> <span class="mf">0.961696</span><span class="p">]</span>
        <span class="n">process_data</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s2">&quot;float&quot;</span><span class="p">)</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data_float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_fit_median"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_fit_median">[docs]</a>    <span class="k">def</span> <span class="nf">test_fit_median</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">process_data</span><span class="p">,</span> <span class="n">cols_transform_value</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;median&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="mf">0.606584</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.193332</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.620475</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.591332</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.327392</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.519504</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.610669</span><span class="p">,</span>
                                            <span class="o">-</span><span class="mf">0.768581</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.28757</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.247477</span><span class="p">]</span>
        <span class="n">test_data_fit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fit_test_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">test_data</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">,</span> <span class="n">imputer_value</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_to_list</span><span class="p">(</span><span class="n">process_data</span><span class="p">),</span> <span class="n">test_data_fit</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_value</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span></div>

<div class="viewcode-block" id="TestMinMaxScaler.test_get_impute_rate"><a class="viewcode-back" href="../../../../federatedml.feature.test.html#federatedml.feature.test.imputer_test.TestMinMaxScaler.test_get_impute_rate">[docs]</a>    <span class="k">def</span> <span class="nf">test_get_impute_rate</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">imputer_value</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">,</span> <span class="s1">&#39;na&#39;</span><span class="p">,</span> <span class="s1">&#39;null&#39;</span><span class="p">,</span> <span class="s2">&quot;10000&quot;</span><span class="p">,</span> <span class="s2">&quot;-10000&quot;</span><span class="p">]</span>
        <span class="n">imputer</span> <span class="o">=</span> <span class="n">Imputer</span><span class="p">(</span><span class="n">missing_value_list</span><span class="o">=</span><span class="n">imputer_value</span><span class="p">)</span>
        <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="s2">&quot;median&quot;</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="s1">&#39;str&#39;</span><span class="p">)</span>
        <span class="n">cols_impute_rate_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
        <span class="n">cols_fit_impute_rate</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">get_impute_rate</span><span class="p">(</span><span class="n">mode</span><span class="o">=</span><span class="s2">&quot;fit&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_fit_impute_rate</span><span class="p">,</span> <span class="n">cols_impute_rate_ground_true</span><span class="p">)</span>

        <span class="n">cols_transform_value_ground_true</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="mf">0.606584</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.193332</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.620475</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.591332</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.327392</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.519504</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.610669</span><span class="p">,</span>
                                            <span class="o">-</span><span class="mf">0.768581</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.28757</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.247477</span><span class="p">]</span>
        <span class="n">_</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">table_instance</span><span class="p">,</span> <span class="n">cols_transform_value_ground_true</span><span class="p">)</span>
        <span class="n">cols_transform_impute_rate</span> <span class="o">=</span> <span class="n">imputer</span><span class="o">.</span><span class="n">get_impute_rate</span><span class="p">(</span><span class="n">mode</span><span class="o">=</span><span class="s2">&quot;fit&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">assertListEqual</span><span class="p">(</span><span class="n">cols_transform_impute_rate</span><span class="p">,</span> <span class="n">cols_impute_rate_ground_true</span><span class="p">)</span></div></div>


<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">unittest</span><span class="o">.</span><span class="n">main</span><span class="p">()</span>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, FATE_TEAM

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>